package com.vanke.eyepetizer

import android.content.Context
import android.widget.ImageView
import com.bumptech.glide.Glide
import com.bumptech.glide.load.DecodeFormat
import com.bumptech.glide.load.engine.DiskCacheStrategy

/**
 * @name EyePetizer
 * @package name：com.vanke.eyepetizer
 * @class describe
 * @anthor shiyuchuan
 * @time 2017/8/8 10:46
 */
class ImageLoadUtils{
    companion object {
        fun display(context: Context, imageView: ImageView?, url: String){
            if (imageView == null) {
                throw IllegalArgumentException()
            }
            Glide.with(context).load(url)
                    .diskCacheStrategy(DiskCacheStrategy.ALL)
                    .centerCrop()
                    .placeholder(R.drawable.ic_image_loading)
                    .error(R.drawable.ic_empty_picture)
                    .crossFade().into(imageView)
        }

        fun displayHigh(context: Context, imageView: ImageView?,url: String) {
            if (imageView == null) {
                throw IllegalArgumentException()
            }
            Glide.with(context).load(url)
                    .asBitmap()
                    .format(DecodeFormat.PREFER_ARGB_8888)
                    .diskCacheStrategy(DiskCacheStrategy.ALL)
                    .centerCrop()
                    .placeholder(R.drawable.ic_image_loading)
                    .error(R.drawable.ic_empty_picture)
                    .into(imageView)
        }
    }
}